<template>
    <h1>视频上传</h1>
    <div>
        <van-uploader
                :after-read="afterRead"
                :before-read="beforeRead"
                accept="video/*"
        />
        <div style="font-size:12px;color:#777">视频大小不能超过100M</div>
      <!--  <van-uploader
                v-model="videoList"
                :max-count="1"
                preview-size="120px"
                accept="video/*"
                :after-read="handlevideosc"
                :before-read="handlebefread"
                @click-preview="handleclicksc"
        >
            <div slot="preview-cover">
                <video
                        style="width:120px;height:120px;object-fit:cover;"
                        :src="videourl"
                        v-if="videourl"
                ></video>
            </div>
        </van-uploader>
        <div style="font-size:12px;color:#777">视频大小不能超过100M</div>
        <van-dialog
                style="width:100%;border-radius:0;height:200px"
                theme="default"
                v-model="showvideoplay"
                :show-cancel-button="false"
                :show-confirm-button="false"
                closeOnClickOverlay
        >
            <video
                    controls
                    preload="auto"
                    style="width:100%;height:200px;object-fit: contain;"
                    :src="videourl"
                    v-if="videourl"
            ></video>
        </van-dialog>-->
    </div>


</template>

<script>
    export default {

        setup() {

            const afterRead = (file) => {
                // 此时可以自行将文件上传至服务器
                console.log(file);

            };
            const beforeRead = (file) => {

                if (file.size > 104857600) {
                    this.$toast("选择/录制视频不能超过100M");
                    return false;
                }
                return true;
            };

            return {
                afterRead,
                beforeRead,
            };
        },
     /*   data() {
            return {

                carinfo: {
                    videofile: "",
                    ngEcoOpenNo: ""
                 },
                videoList: [],

                videourl: "",
                showvideoplay: false
            };
        },*/
        methods: {
            beforeRead(file){
                if (file.size > 104857600){
                    this.$toast("选择/录制视频不能超过100M");
                    return false;
                }
                return true;
            },
            afterRead:function (file) {

                this.axios.post("http://localhost:8080///hy/ossController/uploadVideo.do" + file)
                    .then(function (file) {
                        console.log("运行到内部了")
                    this.$toast("视频上传成功")
                })
                }
            },
          /*  handlebefread(e) {
                if (e.size > 104857600) {
                    this.$Message.error("选择/录制视频不能超过100M");
                    return false;
                }
                return true;
            },
            handlevideosc(file) {
                this.videourl = file.content;
            },
            handleclicksc(file) {
                this.showvideoplay = true;
            },
            handleconfirpop() {
                if (this.videoList.length > 0) {
                    this.carinfo.videofile = this.videoList[0].content;
                }
                //这里写提交后台代码
            },
            handleplay(item) {
                this.show = true;
                this.videoList = [];
                this.carinfo.ngEcoOpenNo = item.ngEcoOpenNo;
            },*/


    }
</script>

<style scoped>

</style>